<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<script type="text/javascript">
    $(function() {
        mallEcardRebateOrderModule.init();
    });
    var mallEcardRebateOrderModule = (function(){

        /*初始化时间查询*/
        var initDate = function(){
            $("input[name='createtime_begin']").attr("class","Wdate").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});});
            $("input[name='createtime_end']").attr("class","Wdate").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});});
        }

        var module = {
            init :function(){
                initDate();
            },
            //设置E卡返点
            setEcardRebate : function(id){
                window.location.href = 'mallEcardRebateController.do?orderdetailview&orderIds='+id;
            },
            //批量设置E卡返点
            batchSetEcardRebate : function(){
                var rowsData = $('#mallEcardRebateList').datagrid('getSelections');
                if (!rowsData || rowsData.length==0) {
                    tip('请选择订单');
                    return;
                }
                var userId = rowsData[0].userid;
                var orderIds = "";
                var temp = true;
                $(rowsData).each(function(index){
                    if(userId != this.userid){
                        tip('同一用户才能设置批量E卡返点');
                        temp = false;
                        return;
                    }else{
                        userId = this.userid
                        if(index == rowsData.length - 1){
                            orderIds += this.id;
                        }else{
                            orderIds += this.id + ",";
                        }
                    }
                });
                if(temp){
                    window.location.href = 'mallEcardRebateController.do?orderdetailview&orderIds='+orderIds;
                }
            }
        }
        return module;
    })();
</script>
<div class="easyui-layout" fit="true">
  <div region="center" style="padding:0px;border:0px">
  <t:datagrid name="mallEcardRebateList" title="订单列表" actionUrl="mallEcardRebateController.do?orderdatagrid" idField="id"
              fit="true" queryMode="group" checkbox="true">
      <t:dgCol title="编号" field="id" hidden="true"></t:dgCol>
      <t:dgCol title="订单单号" field="orderno" query="true"   width="120"></t:dgCol>
      <t:dgCol title="店铺" field="shopname"   width="120"></t:dgCol>
      <t:dgCol title="userid" field="userid" hidden="true"  width="120"></t:dgCol>
      <t:dgCol title="商品金额" field="productmoney"   width="120"></t:dgCol>
      <t:dgCol title="订单金额" field="paymoney"  width="120"></t:dgCol>
      <t:dgCol title="实际支付金额" field="actualPayMoney"  width="120"></t:dgCol>
      <t:dgCol title="订单类型" field="ordertype" query="true" replace="线上商城订单_0,本地服务订单_1,在线充值服务订单_2"  width="120"></t:dgCol>
      <t:dgCol title="订单来源" field="datasource" query="true" replace="商城网页端_0,商城Android端_1,商城IOS端_2,拉货宝网页端_11"  width="120"></t:dgCol>
      <t:dgCol title="买家" field="fullname"  query="true"  width="120"></t:dgCol>
      <t:dgCol title="用户姓名" field="username"  query="true"  width="120"></t:dgCol>
      <t:dgCol title="创建时间" field="createtime" query="true" queryMode="group"  formatter="yyyy-MM-dd hh:mm:ss"  width="120"></t:dgCol>
      <t:dgCol title="支付时间" field="paytime"   formatter="yyyy-MM-dd hh:mm:ss"  width="120"></t:dgCol>
      <t:dgCol title="操作" field="opt" width="100"></t:dgCol>
      <t:dgFunOpt funname="mallEcardRebateOrderModule.setEcardRebate(id)" title="E卡返点" ></t:dgFunOpt>
      <t:dgToolBar title="批量设置E卡返点" icon="icon-add" funname="mallEcardRebateOrderModule.batchSetEcardRebate"></t:dgToolBar>
  </t:datagrid>
  </div>
 </div>